/**
 * Created by Administrator on 2017/6/21 0021.
 */
var F_Pay_Entrance = {
    _init: function () {
        if (B_Login._checkUpdate(), M_HeadFoot._headShow(1), "demo" != M_Init._controller && B_User._isDemoUser()) B_Login._openLogin("background"); else {
            switch (M_Init._clean(), M_Init._controller) {
                case"demo":
                    M_Init._api.innerOperationPayUser = "demoInnerOperationPayUser";
                    break;
                default:
                    M_Init._api.innerOperationPayUser = "innerOperationPayUser"
            }
            M_Init._dateCache.begin = M_Init._dateChoose.begin, M_Init._dateCache.end = M_Init._dateChoose.end, M_Common._getOrderGame("pay", "", "1-2-4"), B_Date._chooseSection({
                autoCommit: !1,
                todayValid: !1
            }, 1, M_Init._dateChoose.begin, M_Init._dateChoose.end, function (a, e) {
                a == M_Init._dateCache.begin && M_Init._dateCache.end == e || (M_Init._dateCache.begin = a, M_Init._dateCache.end = e, F_Pay_Info._getInfo())
            })
        }
    }
}, F_Pay_Info = {
    _init: [{
        type: "togetherTabAvg",
        name: "付费玩家概览",
        tab: ["首次付费数", "当日付费玩家数", "潜在付费玩家数"],
        tips: [{}, {
            position: "second",
            content: ["首日付费玩家数：当日为新增日，且在新增日就进行付费的玩家数<br>首次付费玩家数：当日付费且是历史以来第一次付费的玩家数", "首次付费玩家数：当日付费且是历史以来第一次付费的玩家数<br>再次付费玩家数：当日付费且不是首次付费的玩家数<br>当日付费玩家数：当日付费的玩家总数", "潜在付费玩家：之后7日（不含当日）玩家付费的意愿强度>0.5的玩家数。付费意愿的取值范围为0~1，非常强烈的意愿为1<br>付费玩家总数：当日付费的玩家总数"]
        }]
    }, {
        type: "switchTab",
        name: "已玩天数分布",
        tab: ["付费玩家", "潜在付费玩家"],
        tips: [{}, {
            position: "second",
            content: ["所选时期内有付费行为的玩家玩游戏的实际天数进行分布", "之后7日（不含当日）玩家付费的意愿强度>0.5的玩家已经玩游戏的实际天数分布。付费意愿的取值范围为0~1，非常强烈的意愿为1"]
        }]
    }, {
        type: "switchTab",
        name: "等级分布",
        tab: ["付费玩家", "潜在付费玩家"],
        tips: [{}, {
            position: "second",
            content: ["所选时期内有付费行为的玩家目前的等级进行分布", "之后7日（不含当日）玩家付费的意愿强度>0.5的玩家的等级分布。付费意愿的取值范围为0~1，非常强烈的意愿为1"]
        }]
    }, {
        type: "switchTab",
        name: "当日游戏时长分布",
        tab: ["付费玩家", "潜在付费玩家"],
        tips: [{}, {
            position: "second",
            content: ["所选时期内有付费行为的玩家的付费当日游戏时长分布", "之后7日（不含当日）玩家付费的意愿强度>0.5的玩家的当日游戏时长分布。付费意愿的取值范围为0~1，非常强烈的意愿为1"]
        }]
    }, {
        type: "switchTab",
        name: "中国地区分布",
        tab: ["付费玩家", "潜在付费玩家"],
        tips: [{}, {
            position: "second",
            content: ["所选时期内有付费行为的玩家的地区分布", "之后7日（不含当日）玩家付费的意愿强度>0.5的玩家的地区分布。付费意愿的取值范围为0~1，非常强烈的意愿为1"]
        }]
    }, {
        type: "switchTab",
        name: "全球地区分布",
        tab: ["付费玩家", "潜在付费玩家"],
        tips: [{}, {
            position: "second",
            content: ["所选时期内有付费行为的玩家的地区分布", "之后7日（不含当日）玩家付费的意愿强度>0.5的玩家的地区分布。付费意愿的取值范围为0~1，非常强烈的意愿为1"]
        }]
    }, {
        type: "switch",
        name: "付费玩家流失倾向分析",
        tab: [],
        tips: [{position: "first", content: "付费玩家中可能流失的人数：当日付费的玩家中，之后7日（不含当日）不再登录概率大于50%的玩家数"}]
    }],
    _avg: [[[{label: "AVG：", name: "平均每日首次付费玩家数", key: "avg_first_pay_user", unit: ""}], [{
        label: "AVG：",
        name: "平均每日付费玩家数",
        key: "avg_pay_user",
        unit: ""
    }], [{label: "AVG：", name: "平均每日有付费倾向的玩家数", key: "avg_potential_pay", unit: ""}]]],
    _port: [[[{name: "首日付费玩家数", key: "y_axis_first_day_pay"}, {
        name: "首次付费玩家数",
        key: "y_axis_first_pay"
    }], [{name: "首次付费玩家数", key: "y_axis_first_pay"}, {name: "再次付费玩家数", key: "y_axis_pay_again"}, {
        name: "当日付费玩家数",
        key: "y_axis_pay"
    }], [{name: "潜在付费用户", key: "y_axis_potential_pay"}, {name: "当日付费玩家数", key: "y_axis_pay"}]], [[{
        name: "已付费",
        key: "pay_user_oldays_distri|paid"
    }], [{name: "潜在付费", key: "pay_user_oldays_distri|potential_pay"}]], [[{
        name: "已付费",
        key: "pay_user_level_distri|paid"
    }], [{name: "潜在付费", key: "pay_user_level_distri|potential_pay"}]], [[{
        name: "已付费",
        key: "pay_user_oltime_distri|paid"
    }], [{name: "潜在付费", key: "pay_user_oltime_distri|potential_pay"}]], [[{
        name: "已付费",
        key: "pay_user_area_distri|paid|china"
    }], [{name: "潜在付费", key: "pay_user_area_distri|potential|china"}]], [[{
        name: "已付费",
        key: "pay_user_area_distri|paid|global"
    }], [{name: "潜在付费", key: "pay_user_area_distri|potential|global"}]], [[{
        name: "可能流失的付费玩家",
        key: "pay_user_potential_lost_distri"
    }]]],
    _domInit: function () {
        M_Inside._htmlChartTable($("#ct_main_area"), F_Pay_Info._init), M_Inside._downloadCsv(), F_Pay_Info._getInfo()
    },
    _getInfo: function () {
        for (var a = M_Init._dateCache.begin, e = M_Init._dateCache.end, _ = [], t = 0; t < F_Pay_Info._init.length; t++)_.push("bs_chart_" + t + "_0");
        var n = {};
        n.start_date = a, n.end_date = e, n.game_id = M_Init._gameId, n = B_Common._postData(n), B_Port._ajax(M_Init._api.innerOperationPayUser, "post", !0, n, function () {
            for (var a = 0; a < _.length; a++)$("#" + _[a]).html(B_Pre._loading())
        }, function () {
            for (var a = 0; a < _.length; a++)$("#" + _[a]).html("")
        }, function (a, e) {
            if (a) {
                M_Init._dataCache.data = a;
                for (var _ = 0; _ < F_Pay_Info._init.length; _++)if (F_Pay_Info._init[_].tab.length > 0) {
                    M_Init._dataCache["position_" + _] || (M_Init._dataCache["position_" + _] = 0);
                    for (var t = 0; t < F_Pay_Info._init[_].tab.length; t++)if (M_Init._dataCache["position_" + _] == t) {
                        F_Pay_Info._chartHtml(_, t), M_Inside._chartTableIcon(F_Pay_Info._init[_].type, _, t);
                        break
                    }
                    M_Inside._tabChangePerChart(_, F_Pay_Info._init[_].type, "pay")
                } else F_Pay_Info._chartHtml(_, 0), M_Inside._chartTableIcon(F_Pay_Info._init[_].type, _, 0)
            }
        }, function (a, e, t) {
            for (var n = 0; n < _.length; n++)$("#" + _[n]).html(B_Pre._empty(e))
        })
    },
    _chartHtml: function (a, e, _) {
        M_Init._dataCache["position_" + a] = e;
        var t = M_Init._dataCache.data, n = {x_axis: [], y_axis: [], yFormat: ""}, i = {}, s = 50, o = "";
        switch (a + "") {
            case"0":
                switch (n.xFormatDate = !0, n.yFormat = "", n.tooltip = {num: 2, unit: "人"}, o = "人", e + "") {
                    case"1":
                        n.tooltip = {num: 3, unit: "人"}
                }
                break;
            case"1":
            case"2":
            case"3":
            case"4":
            case"5":
                n.tooltip = {num: 1, unit: "人"};
                break;
            case"6":
                n.xFormatDate = !0, n.yFormat = "", n.tooltip = {num: 1, unit: "人"}, o = "人"
        }
        switch (a + "") {
            case"1":
                i = {head: ["已玩天数", F_Pay_Info._port[a][e][0].name + "(人)", "玩家占比"], body: []};
                break;
            case"2":
                i = {head: ["玩家等级分布", F_Pay_Info._port[a][e][0].name + "(人)", "玩家占比"], body: []};
                break;
            case"3":
                i = {head: ["人均活跃时长", F_Pay_Info._port[a][e][0].name + "(人)", "玩家占比"], body: []};
                break;
            case"4":
            case"5":
                i = {head: ["地区", F_Pay_Info._port[a][e][0].name + "(人)", "玩家占比"], body: []};
                break;
            case"6":
                i = {head: ["日期", F_Pay_Info._port[a][e][0].name + "(人)", "玩家占比"], body: []};
                break;
            default:
                i = {head: ["日期"], body: []}
        }
        for (var y = 0; y < F_Pay_Info._port[a][e].length; y++) {
            var r = F_Pay_Info._port[a][e][y].key.split("|"), d = F_Pay_Info._port[a][e][y].name;
            if (1 == a) {
                if (s = 20, t[r[0]][r[1]]) {
                    for (var p = t[r[0]][r[1]], l = [], h = 0; h < p.length; h++)p[h].oldays_classify = p[h].oldays_classify.replace("&gt;", ">"), p[h].oldays_classify = p[h].oldays_classify.replace("&lt;", "<"), n.x_axis.push(p[h].oldays_classify), l.push(p[h].user_num), i.body[h] || (i.body[h] = [p[h].oldays_classify]), i.body[h].push(p[h].user_num), i.body[h].push(p[h].user_rate + "%");
                    n.y_axis.push({name: d, data: l})
                }
            } else if (2 == a) {
                if (s = 40, t[r[0]][r[1]]) {
                    for (var p = t[r[0]][r[1]], l = [], h = 0; h < p.length; h++)n.x_axis.push(p[h].level + "级"), l.push(p[h].user_num), i.body[h] || (i.body[h] = [p[h].level + "级"]), i.body[h].push(p[h].user_num), i.body[h].push(p[h].user_rate + "%");
                    n.y_axis.push({name: d, data: l})
                }
            } else if (3 == a) {
                if (s = 20, t[r[0]][r[1]]) {
                    for (var p = t[r[0]][r[1]], l = [], h = 0; h < p.length; h++)p[h].oltime_classify = p[h].oltime_classify.replace("&gt;", ">"), p[h].oltime_classify = p[h].oltime_classify.replace("&lt;", "<"), n.x_axis.push(p[h].oltime_classify), l.push(p[h].user_num), i.body[h] || (i.body[h] = [p[h].oltime_classify]), i.body[h].push(p[h].user_num), i.body[h].push(p[h].user_rate + "%");
                    n.y_axis.push({name: d, data: l})
                }
            } else if (4 == a || 5 == a) {
                if (s = 20, t[r[0]][r[1]][r[2]]) {
                    for (var p = t[r[0]][r[1]][r[2]], l = [], h = 0; h < p.length; h++)n.x_axis.push(p[h].area_classify), l.push(p[h].user_num), i.body[h] || (i.body[h] = [p[h].area_classify]), i.body[h].push(p[h].user_num), i.body[h].push(p[h].user_rate + "%");
                    n.y_axis.push({name: d, data: l})
                }
            } else if (6 == a) {
                if (t[r[0]]) {
                    for (var p = t[r[0]], l = [], h = 0; h < p.length; h++)n.x_axis.push(p[h].data_date), l.push(p[h].potential_lost_num), i.body[h] || (i.body[h] = [p[h].data_date]), i.body[h].push(p[h].potential_lost_num), i.body[h].push(p[h].potential_lost_rate + "%");
                    n.y_axis.push({name: d, data: l})
                }
            } else if (s = 50, n.x_axis = t.x_axis, "%" != o ? i.head.push(F_Pay_Info._port[a][e][y].name + "(" + o + ")") : i.head.push(F_Pay_Info._port[a][e][y].name), t[r[0]]) {
                for (var p = t[r[0]], h = 0; h < p.length; h++)i.body[h] || (i.body[h] = [t.x_axis[h]]), "%" != o ? i.body[h].push(p[h]) : i.body[h].push(p[h] + o);
                n.y_axis.push({name: d, data: p})
            }
        }
        if (F_Pay_Info._avg[a] && F_Pay_Info._avg[a][e]) {
            for (var c = "", m = F_Pay_Info._avg[a][e], u = 0; u < m.length; u++)m[u].label && (c += "<span>" + m[u].label + "</span>"), c += "<span>" + m[u].name + "<b>", r = m[u].key.split("|"), t[r[0]] && (c += t[r[0]]), c += m[u].unit + "</b></span>";
            M_Inside._avgHtml(a + "_0", c)
        }
        i.name = M_Inside._tableName(F_Pay_Info._init, a, e, M_Init._dateCache.begin, M_Init._dateCache.end), e = 0, M_Init._dataCache[a + "_" + e] = i, M_Inside_Chart._chartData(s, "bs_chart_" + a + "_" + e, n), M_Inside._tableHtml(1, a + "_" + e)
    }
};